home *** CD-ROM | disk | FTP | other *** search
- unit Ufinder;
-
- interface
-
- uses
- WinTypes, WinProcs, SysUtils, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, TFind, FileCtrl, ExtCtrls, ShellAPI;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- FileSpec: TEdit;
- Go: TBitBtn;
- Label1: TLabel;
- Bevel1: TBevel;
- GroupBox1: TGroupBox;
- CheckBox1: TCheckBox;
- CheckBox2: TCheckBox;
- CheckBox3: TCheckBox;
- CheckBox4: TCheckBox;
- CheckBox5: TCheckBox;
- CheckBox6: TCheckBox;
- GroupBox2: TGroupBox;
- CheckBox7: TCheckBox;
- CheckBox8: TCheckBox;
- CheckBox9: TCheckBox;
- Button1: TButton;
- GroupBox3: TGroupBox;
- CheckBox10: TCheckBox;
- CheckBox11: TCheckBox;
- Header1: THeader;
- procedure GoClick(Sender: TObject);
- procedure CheckBox1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure FileSpecChange(Sender: TObject);
- procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- procedure Header1Sized(Sender: TObject; ASection, AWidth: Integer);
- procedure ListBox1DblClick(Sender: TObject);
- private
- { Private declarations }
- SearchFlags: Word;
- procedure MyProgressHook (Sender: TObject; const Dir: String);
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.MyProgressHook (Sender: TObject; const Dir: String);
- begin
- Caption := 'Scanning: ' + Dir;
- end;
-
- procedure TForm1.GoClick(Sender: TObject);
- var
- tf: TTreeFind;
- begin
- ListBox1.Clear;
-
- tf := TTreeFind.Create;
- tf.FileSpec := FileSpec.Text;
- tf.SearchFlags := SearchFlags;
- tf.Progress := Self.MyProgressHook;
-
- Go.Enabled := False;
- tf.Execute;
- Caption := 'TreeFind Testbed';
- Go.Enabled := True;
-
- if tf.TheList.Count = 0 then
- Listbox1.Items.Add ('No matching files found')
- else
- ListBox1.Items.Assign (tf.TheList);
-
- tf.Free;
- end;
-
- procedure TForm1.CheckBox1Click (Sender: TObject);
- begin
- with Sender as TCheckBox do
- if Checked then SearchFlags := SearchFlags or Tag
- else
- SearchFlags := Searchflags and (not Tag);
-
- CheckBox10.Enabled := not CheckBox11.Checked;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TForm1.FileSpecChange(Sender: TObject);
- var
- DrvFlgs: Boolean;
- begin
- DrvFlgs := (Length (FileSpec.Text) < 2) or (FileSpec.Text[2] <> ':');
- CheckBox1.Enabled := DrvFlgs;
- CheckBox2.Enabled := DrvFlgs;
- CheckBox3.Enabled := DrvFlgs;
- CheckBox4.Enabled := DrvFlgs;
- CheckBox5.Enabled := DrvFlgs;
- CheckBox6.Enabled := DrvFlgs;
- end;
-
- function NextSection (var Str: String): String;
- var
- idx: Integer;
- begin
- if Str <> '' then idx := Pos (#9, Str) else idx := 0;
- if idx = 0 then
- begin
- NextSection := Str;
- Str := '';
- end
- else
- begin
- NextSection := Copy (Str, 1, idx - 1);
- Delete (Str, 1, idx);
- end;
- end;
-
- procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- var
- Str: String;
- x, idx: Integer;
- begin
- with ListBox1, ListBox1.Canvas, Header1 do
- begin
- idx := 0;
- FillRect (Rect);
- x := Rect.left + 3;
- Str := Items [Index];
- while Str <> '' do
- begin
- TextOut (x, Rect.top, NextSection (Str));
- Inc (x, SectionWidth [idx]);
- Inc (idx);
- end;
- end;
- end;
-
- procedure TForm1.Header1Sized(Sender: TObject; ASection, AWidth: Integer);
- begin
- ListBox1.Invalidate;
- end;
-
- procedure TForm1.ListBox1DblClick(Sender: TObject);
- var
- fName: String;
- TabPos: Integer;
- begin
- with ListBox1 do
- if ItemIndex <> -1 then
- begin
- fName := Items [ItemIndex];
- { Is this a ZIP entry ? }
- TabPos := Pos (#9, fName);
- if TabPos <> 0 then fName := Copy (fName, TabPos + 1, 255);
- ShellExecute (Handle, 'open', PChar (fName), Nil, Nil, SW_ShowNormal);
- end;
- end;
-
- end.
-
-
-
-